package com.xdap.wecom.controller;

import com.alibaba.fastjson.JSONArray;
import com.definesys.mpaas.common.http.Response;
import com.xdap.common.pojo.dto.webhook.WebhookProcessDto;
import com.xdap.wecom.service.WecomWebhookService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ProjectName techking-plan-plugin
 * @Description
 * @Date 2023/11/16 10:24
 * @Author shangsheng.li
 **/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/techking/webhook")
public class WecomWebHookController {

    @Resource
    private WecomWebhookService webhookService;

    /**
     * @Description 推送企业微信消息
     * @Date 2023/9/13 9:24
     * @Author shangsheng.li
     **/
    @PostMapping("/wecom/todo")
    public Response wxApproveMsgSend(@RequestBody WebhookProcessDto webhookProcessPojo) {
        log.info("接口入参：{}", JSONArray.toJSONString(webhookProcessPojo));
        Response response = webhookService.wxApproveMsgSend(webhookProcessPojo);
        return response;
    }

    /**
     * @Description 定时重推未完成任务
     * @Date 2023/9/13 9:24
     * @Author shangsheng.li
     **/
    @PostMapping("/wecom/rePush")
    public Response rePushWxMsg() {
        Response response = webhookService.rePushWxMsg();
        return response;
    }


}
